package com.azkj.album.adapter;

import android.widget.CheckBox;

import com.azkj.album.R;
import com.azkj.album.dto.Pics;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.ArrayList;

public class PicsAdapter extends BaseQuickAdapter<Pics, BaseViewHolder> {

    private boolean isShowSelect = false;

    private boolean isAllSelect = false;

    public void setShowSelect(boolean isShowSelect){
        this.isShowSelect = isShowSelect;
        notifyDataSetChanged();
    }

    public void setAllSelect(boolean isAllSelect){
        this.isAllSelect = isAllSelect;
        for (Pics datum : getData()) {
            datum.isSelect = isAllSelect;
        }
        notifyDataSetChanged();
    }
    public PicsAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, Pics item) {
        RoundedImageView iv = helper.getView(R.id.iv_image);
        CheckBox cb_select = helper.getView(R.id.iv_image_select);
        Glide.with(mContext).load(item.url).into(iv);
        helper.setVisible(R.id.iv_image_select, isShowSelect);
        if (item.isSelect) {
            cb_select.setButtonDrawable(R.mipmap.ic_new_photo_yes_select);
        } else {
            cb_select.setButtonDrawable(R.mipmap.ic_new_photo_no_select);
        }
    }
}
